import request from '@/common/request.js'

// 上传文件
export function uploadFile(filePath) {
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: request.baseUrl + '/api/user/upload',
			filePath: filePath,
			name: 'file',
			header: {
				'token': uni.getStorageSync('token')
			},
			success: (res) => {
				const data = JSON.parse(res.data)
				resolve(data)
			},
			fail: (error) => {
				reject(error)
			}
		})
	})
}

// 更新用户信息
export function updateUserInfo(data) {
	return request.httpTokenRequest({
		url: '/api/user/updateUserInfo',
		method: 'post',
		data
	})
}

// 注销账户
export function deleteAccount() {
	return request.httpTokenRequest({
		url: '/api/user/delete',
		method: 'post'
	})
}